<?php

    class StaticController extends Zend_Controller_Action
    {

        public function init()
        {
            /* Initialize action controller here */
        }

        public function indexAction()
        {
            $static_key = trim($this->getParam("page"));

            $model = new Application_Model_Common();
            $record = $model->getAllRecordDetail(TABLE_STATIC_PAGES, "static_page_key='$static_key'");
            if (!empty($record))
            {
                $pageTitle = $record[0]["static_page_title"];
                $pageContent = $record[0]["static_page_content"];

                $this->view->pageTitle = $pageTitle;
                $this->view->pageContent = $pageContent;
            }
            else
            {
                $this->view->pageContent = "No such record found";
            }
        }

        public function postadAction()
        {
            $x = new Zend_Auth_Storage_Session('User_Auth');
            $y = $x->read();
            if (!empty($y))
            {
                $this->view;
                if ($this->getRequest()->isPost())
                {
                    $arr = $this->getRequest()->getPost();
                    $arr["ad_user_id"] = $x->read()->user_id;
                    $model = new Application_Model_Common();
                    $model->insertRecordData($arr, TABLE_ADS);
                    $_SESSION["messageSuccess"] = "Your ad has been submitted for approval";
                    $this->redirect("profile");
                }
            }
            else
            {
                $this->redirect("profile");
            }
        }

    }

    